package com.reformer.commons.exception;

import com.reformer.commons.constant.ErrorMsg;

public class ResultException extends RuntimeException {

    /**
     *
     */
    private static final long serialVersionUID = 1L;

    private String errno = "505";

    public ResultException() {
        super();
    }

    public ResultException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
        super(message, cause, enableSuppression, writableStackTrace);
    }

    public ResultException(String message, Throwable cause) {
        super(message, cause);
    }

    public ResultException(String message) {
        super(message);

    }

    public ResultException(Throwable cause) {
        super(cause);
    }

    public ResultException(String errno, String message) {
        super(message);
        this.errno = errno;
    }

    public ResultException(ErrorMsg errorMsg) {
        super(errorMsg.getErrmsg());
        this.errno = errorMsg.getErrno();
    }

    public String getErrno() {
        return errno;
    }

    @Override
    public String toString() {
        String s = this.getClass().getName();
        String message = getLocalizedMessage();
        return (message != null) ? (s + ": " + message + "ERRNO: " + errno) : s + "ERRNO: " + errno;
    }


}
